package cn.lan.generator.factory;

import cn.lan.generator.service.EntityService;
import cn.lan.generator.service.impl.DB2EntityServiceImpl;
import cn.lan.generator.service.impl.MySQLEntityServiceImpl;
import cn.lan.generator.service.impl.SQLServerEntityServiceImpl;
import cn.lan.generator.utils.Constant;

import javax.xml.bind.ValidationException;

public class EntityServiceFactory {


    /**
     * 获取entityService
     * @param dbType
     * @return
     * @throws ValidationException
     */
    public static EntityService getEntityService(String dbType) throws ValidationException {
        if (Constant.DB_TYPE_MYSQL.equals(dbType)) {
            return new MySQLEntityServiceImpl();
        }else if (Constant.DB_TYPE_DB2.equals(dbType)) {
            return new DB2EntityServiceImpl();
        } else if (Constant.DB_TYPE_SQLSERVER.equals(dbType)) {
           return new SQLServerEntityServiceImpl();
        }
        throw new ValidationException("数据库类型 dbType 参数错误");
    }
}
